angular.module('user_register', [])
    .controller('user_registerCtrl', function ($rootScope, $scope, $state, httpUtil, alertModule) {
        $scope.user = {
            username: '',
            password: '',
            nickname: ''
        };

        $scope.userRegister = function () {
            var params = $scope.user;
            if(params.username == null || params.username == '' || params.password == null || params.password == '' || params.nickname == null || params.nickname == ''){
                alertModule.alertMessage("用户名、密码、昵称不能为空！");
                return false;
            }
            httpUtil.httpSend("User_userRegister.action", params, function (data) {
                if(data.success){
                    httpUtil.httpSend("User_userLogin.action", params, function (data) {
                        $rootScope.user = data.data;
                        $state.go('main.music_information');
                    });
                } else {
                    alertModule.alertMessage(data.msg);
                }
            });
        };
    });